﻿Imports System.Data
Imports System.Data.OleDb
Imports geraLaudosAutomatico.conexao
Imports System.Text

Public Class secaoDAO

    Private sql As New StringBuilder
    Private objConn As New conexao
    Private i As Integer
    Private secao As New secaoVO



    Public Function getSecoes() As Generic.List(Of secaoVO)

        sql.Clear()
        sql.Append("SELECT *FROM secao ORDER BY DESC_SECAO")

        Dim oReader As OleDbDataReader

        Dim lista As New Generic.List(Of secaoVO)



        Try
            Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao)

            oReader = oComando.ExecuteReader

            While oReader.Read

                secao = New secaoVO
                secao.ID_SECAO = oReader("ID_SECAO")
                secao.desc_secao = oReader("DESC_SECAO")
                secao.STATUS = oReader("STATUS")
                lista.Add(secao)
            End While

            Return lista

        Catch ex As Exception

            Throw ex

        Finally

            objConn.fechaConexao()

        End Try

    End Function



    Public Function getsecao(ByVal id_secao As Integer) As secaoVO

        sql.Clear()
        sql.Append("SELECT *FROM secao WHERE ID_secao=" & id_secao)

        Dim oReader As OleDbDataReader

        Try
            Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao)

            oReader = oComando.ExecuteReader

            While oReader.Read
                secao = New secaoVO
                secao.id_secao = oReader("ID_SECAO")
                secao.desc_secao = oReader("DESC_SECAO")
                secao.status = oReader("STATUS")

            End While

            Return secao

        Catch ex As Exception

            Throw ex

        Finally

            objConn.fechaConexao()

        End Try

    End Function

End Class
